package com.freecloud.javabasics.design.factory.simple;

import com.freecloud.javabasics.design.entity.car.BMW;
import com.freecloud.javabasics.design.entity.Food;
import com.freecloud.javabasics.design.entity.Product;
import com.freecloud.javabasics.design.entity.UnknownProduct;

/**
 * 简单工厂模式
 *
 * 根据指定类型，获得具体实现
 *
 * @Author: maomao
 * @Date: 2019-10-30 08:54
 */
public class ProductFactory {


    public static Product getProduct(String name){
        if("food".equals(name)){
            return new Food();
        }else if("car".equals(name)){
            return new BMW();
        }
        return new UnknownProduct();
    }
}
